/*
    Speedbump aka Project Kimbula
    Copyright (C) 2010  Ping Shin Ching

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see http://www.gnu.org/licenses.

	Ping Shin Ching
	righteous.ninja@gmail.com OR ping_sc@hotmail.com
	More information at http://www.tidytutorials.com/p/speedbump.html
 */


#include "responsehelper.h"
#include <string.h>
#include <stdio.h>

/*************************************************************************
 * Get the response for CONNECT
 *************************************************************************/
const char* ResponseHelper::GetCONNECTOK(){
	return "HTTP/1.0 200 Connection Established\r\nProxy-Agent: Speedbump\r\n\r\n";
}


/*************************************************************************
 * Get the response for CONNECT
 *************************************************************************/
const char* ResponseHelper::GetCONNECTKO(){
	return "";
}


/*************************************************************************
 * Remote connection to host fails
 *************************************************************************/
const char* ResponseHelper::GetRemoteHostConnectKO(){
	return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 24\r\n\r\nError connecting to host";
}


/*************************************************************************
 * Create a response from message text
 *************************************************************************/
char* ResponseHelper::CreateMessageOK(char* msgbuffer, int msgbuffersize, const char* msg){
	snprintf(msgbuffer, msgbuffersize-1, "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n%s", (int)strlen(msg), msg);
	return msgbuffer;
}
